package com.canopys.study.open.opensource.sm.listener;

import com.canopys.study.open.opensource.sm.DemoStateMachine;
import com.canopys.study.open.opensource.sm.domain.DemoDomain;
import com.canopys.study.open.opensource.sm.event.DemoEvent;
import com.canopys.study.open.opensource.sm.state.DemoState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.squirrelframework.foundation.fsm.StateMachine;
import org.squirrelframework.foundation.fsm.annotation.OnActionExecException;
import org.squirrelframework.foundation.fsm.annotation.OnAfterActionExecuted;
import org.squirrelframework.foundation.fsm.annotation.OnBeforeActionExecuted;
import org.squirrelframework.foundation.fsm.annotation.OnTransitionBegin;
import org.squirrelframework.foundation.fsm.annotation.OnTransitionComplete;
import org.squirrelframework.foundation.fsm.annotation.OnTransitionDecline;
import org.squirrelframework.foundation.fsm.annotation.OnTransitionEnd;
import org.squirrelframework.foundation.fsm.annotation.OnTransitionException;
import org.squirrelframework.foundation.fsm.impl.AbstractUntypedStateMachine;

/**
 * @Author: Canopys
 * @Descrption:
 * @Date: Created in 13:07 2019/3/24
 * @Modified By:
 */
@Slf4j
@Service
public class DemoListener {

    @OnTransitionBegin
    public void transitionBegin(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------transitionBegin--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnBeforeActionExecuted
    public void beforeActionExec(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------beforeActionExec--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnActionExecException
    public void actionExecException(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------actionExecException--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnAfterActionExecuted
    public void afterActionExec(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------afterActionExec--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnTransitionComplete
    public void transitionComplete(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------transitionComplete--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnTransitionEnd
    public void transitionEnd(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------transitionEnd--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnTransitionException
    public void transitionException(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------transitionException--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }

    @OnTransitionDecline
    public void transitionDecline(DemoState fromState, DemoState toState, DemoEvent event, DemoDomain domain) {
        log.info("-----------------------------transitionDecline--------------------------");
        //log.info("-----------------------------{}--------------------------", this.getCurrentState());
    }
}
